import 'package:json_annotation/json_annotation.dart';

import 'converter/datetime_converter.dart';
import 'model.dart';

// 注意：默认方式不用加路径 "generated"。
// part 'user.g.dart';
part 'generated/user.g.dart';

@JsonSerializable(converters: [DateTimeConverter()])
class User  extends Model<User>{
  @override
  final String id;
  final String username;
  final String nickname;
  final String email;
  final String address;

  //  @DateTimeConverter() // 像这样
  final DateTime createAt;
  final DateTime updateAt;

  const User({
    required this.id,
    required this.username,
    required this.nickname,
    required this.createAt,
    required this.updateAt,
    required this.email,
    required this.address,
  });

  factory User.fromJson(Map<String, dynamic> json) => _$UserFromJson(json);

  Map<String, dynamic> toJson() => _$UserToJson(this);
}
